package com.es.designmode.memento;

/**
 * 发起人
 *
 * @author Will
 */
public class Originator {

    /**
     * 需要保存的属性
     */
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    /**
     * 创建备忘录
     *
     * @return
     */
    public Memento createMemento() {
        return new Memento(state);
    }

    /**
     * 恢复备忘录
     *
     * @param memento
     */
    public void setMemento(Memento memento) {
        state = memento.getState();
    }

    public void show() {
        System.out.println("state = " + state);
    }
}
